package com.nosweattechnet.mapmyway;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class ReportPlace extends Activity {

	String userid;
	String placeid;
	String placename;
	
    @Override
    //Gets the information form the previous activity
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        placeid=intent.getStringExtra(getString(R.string.place_id_intent));
        placename=intent.getStringExtra(getString(R.string.name_of_place));
        userid=intent.getStringExtra(getString(R.string.user_id_intent));
        
        setContentView(R.layout.activity_report);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_report, menu);
        return true;
    }
    
    //Submits the report
    public void sendReport(View view)
    {
    	EditText report = (EditText) findViewById(R.id.report_message);
    	String message = report.getText().toString();
    	Intent send_email = new Intent(Intent.ACTION_SEND);
    	send_email.setType("message/rfc822");
    	send_email.putExtra(Intent.EXTRA_EMAIL, new String[]{getString(R.string.contact_email)});
    	send_email.putExtra(Intent.EXTRA_SUBJECT, "Report: PlaceId: " + placeid + ", PlaceName: " + placename + ", UserId: " + userid);
    	send_email.putExtra(Intent.EXTRA_TEXT, message);
    	try {
    		startActivity(Intent.createChooser(send_email, getString(R.string.sending_mail)));
    	} catch (android.content.ActivityNotFoundException ex) {
    	    Toast.makeText(ReportPlace .this, getString(R.string.no_email_client), Toast.LENGTH_SHORT).show();
    	} 
    	finish();
    }
}
